#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Farmer Li, 公众号: 很酷的程序员/RealCoolEngineer
# @Date: 2021-04-14
# @Question: https://www.zhihu.com/question/453942019

import json

import click


def demo(param: dict):
    for k, v in param.items():
        print(f'{k}: {v}')


def demo2(param_str: str):
    param = json.loads(param_str)
    demo(param)


@click.command()
@click.option('-n', '--name')
@click.option('-a', '--age')
@click.option('-s', '--sex')
def main(name, age, sex):
    param = {'name': name, 'age': age, 'sex': sex}
    demo(param)
    print('=======')
    demo2(json.dumps(param))


if __name__ == '__main__':
    main()
